package com.twetec.cms.common.constant;

import java.util.HashMap;
import java.util.Map;

/**
 * 证件类型
 */
public enum CredentialTypeEnum {

    ID_CARD("ID_CARD", "身份证"),
    PASSPORT_CARD("PASSPORT_CARD", "护照"),
    TAIWAN_COMPATRIOTS_CARD("TAIWAN_COMPATRIOTS_CARD", "台胞证"),
    GO_HOME_CARD("GO_HOME_CARD", "回乡证");

    private String value;
    private String name;

    private CredentialTypeEnum(String value, String name) {
        this.value = value;
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public String getName() {
        return name;
    }

    // 整理返回数据, 键值对
    public static Map<String, String> list() {
        Map<String, String> list = new HashMap<>();
        for (CredentialTypeEnum credentialTypeEnum : CredentialTypeEnum.values()) {
            String name = credentialTypeEnum.getName();
            list.put(String.valueOf(credentialTypeEnum), name);
        }

        return list;
    }

    // 通过value获取name
    public static String getNameByValue(String value) {
        String name = "";
        for (CredentialTypeEnum credentialTypeEnum : CredentialTypeEnum.values()) {
            if (credentialTypeEnum.getValue().equals(value)) {
                name = credentialTypeEnum.getName();
            }
        }

        return name;
    }
}
